package com.csw.util;

import com.csw.pojo.Brand;
import com.csw.pojo.Cell;
import com.csw.pojo.Layer;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2022/11/30 3:36
 */
public class LayerUtil {

    public static Layer bulid(int rowNum,int colNum) {
        Layer layer = null;
        try {
            layer = new Layer(rowNum, colNum);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Brand[] brands = BrandUtil.bulidBrands(layer.getCapacity());
        int flag=0;
        Cell[][] cells = layer.getCells();
        for (int i = 0; i < cells.length; i++) {
            for (int j = 0; j < cells[i].length; j++) {
                Cell cell = new Cell();
                Brand brand = brands[flag++];

                cell.setState(1);
                cell.setBrand(brand);
                cells[j][i]=cell;
                brand.setCell(cell);
            }
        }

//        layer.show();
        return layer;
    }

    public static void main(String[] args) throws Exception {
        bulid(6, 6);
    }
}
